package com.example.myapplication2;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

public class Main2ActivityNewPage extends AppCompatActivity {

    private TextView txt;
    private Button btn;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main2_new_page);

        txt = (TextView) findViewById(R.id.resMsg);
        btn = (Button) findViewById(R.id.btnRes);

        Intent intent = getIntent();
        txt.setText(intent.getIntExtra("num", 0)
                    + ":"
                    + intent.getStringExtra("msg"));

        btn.setOnClickListener(new View.OnClickListener(){
            public void onClick(View v){
                Intent intent = new Intent(Main2ActivityNewPage.this, MainActivity.class);
                intent.putExtra("msg", "I'm fine FAQ");
                setResult(RESULT_OK, intent);
                finish();
            }
        });
    }
}
